package com.wzy.business.store.main

import android.view.KeyEvent
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.BarUtils
import com.blankj.utilcode.util.ToastUtils
import com.wangzhenyu.common.util.exts.singleClick
import com.wangzhenyu.common.base.BasePreImpl
import com.wangzhenyu.common.base.BasePresenter
import com.wangzhenyu.common.base.BaseVBPActivity
import com.wzy.business.R
import com.wzy.business.databinding.BusinessActivityShopWaitApplyBinding
import com.wzy.business.store.me.HelpDocActivity
import com.wzy.business.util.OtherUtils

class ShopWaitApplyActivity :
    BaseVBPActivity<BusinessActivityShopWaitApplyBinding, BasePresenter>() {

    override fun useLightMode() = false

    override fun useBaseLayout() = false

    override fun createPresenter() = BasePreImpl()

    override fun getViewBinding() = BusinessActivityShopWaitApplyBinding.inflate(layoutInflater)

    override fun initView() {
        //去掉状态栏
        BarUtils.transparentStatusBar(this)
        //搞了一个自定义的状态栏
        val statusBarHeight = BarUtils.getStatusBarHeight()
        mBinding.viStatusBar.layoutParams.height = statusBarHeight
        mBinding.viStatusBar.setBackgroundColor(ContextCompat.getColor(this, R.color.primary))

        mBinding.tvHelpCenter.singleClick {
           ActivityUtils.startActivity(HelpDocActivity::class.java)
        }
        //设置该用户别名
         OtherUtils.setJPushAlias()
    }

    //双击退出应用
    private var mExitTime: Long = 0

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (System.currentTimeMillis() - mExitTime > 2000) {
                ToastUtils.showLong("再按一次返回桌面")
                mExitTime = System.currentTimeMillis()
            } else {
                AppUtils.exitApp()
            }
            return true
        }
        return super.onKeyDown(keyCode, event)
    }

}